package controller.menubar;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;

import model.GlobalParams;

import view.MainFrame;

public class QuitListener implements ActionListener {
	
	public QuitListener(MainFrame f) {
		frame = f;		
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {	
		Boolean s = true;
		if (s)		
			createConfirmDialog(s);
		else 
			createConfirmDialog(s);
	}	
	
	
	public void createConfirmDialog(Boolean s) {
		
		String quit_question;	
		
		if (s)		
			quit_question = GlobalParams.getInstance().stringCollection.getQuit_question();
		else 
			quit_question = GlobalParams.getInstance().stringCollection.getQuit_question();
		
		String quit_titlewindow = GlobalParams.getInstance().stringCollection.getQuit_tittle();		
		
	    int response = JOptionPane.showConfirmDialog(null, quit_question, quit_titlewindow,
	    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
	    
	    if (response == JOptionPane.YES_OPTION) {
	    	 frame.setVisible(false);
		     frame.dispose();	   
	    }
		
	}
	
	private MainFrame frame;

}
